//
//  ZJStudySpecialTableViewCell.m
//  LovingPartyBuilding
//
//  Created by ZJ on 2017/5/2.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJStudySpecialTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface ZJStudySpecialTableViewCell ()
/** 图书图片 */
@property (nonatomic, strong) UIImageView *imageview;

/** 题目 */
@property (nonatomic, strong) UILabel *titleLabel;
/** 简介 */
@property (nonatomic, strong) UILabel *abstract;
/** 分割线 */
@property (nonatomic, strong) UILabel *underline;
@end

@implementation ZJStudySpecialTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self.contentView addSubview:self.imageview];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.abstract];
        [self.contentView addSubview:self.underline];
        
        self.underline.sd_layout
        .bottomSpaceToView(self.contentView, 0)
        .leftSpaceToView(self.contentView, 0)
        .rightSpaceToView(self.contentView, 0)
        .heightIs(7.5 * [UIScreen zj_screenHScale]);
        
        self.imageview.sd_layout
        .leftSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .topSpaceToView(self.contentView, 12 * [UIScreen zj_screenHScale])
        .heightIs(172 * [UIScreen zj_screenHScale]);
        
        self.titleLabel.sd_layout
        .topSpaceToView(self.imageview, 8 * [UIScreen zj_screenHScale])
        .leftEqualToView(self.imageview)
        .rightEqualToView(self.imageview)
        .heightIs([NSString heightWithTextFontSize:[UIFont titleTextFontSize]]);
        
        
        self.abstract.sd_layout
        .topSpaceToView(self.titleLabel, 0)
        .leftEqualToView(self.titleLabel)
        .widthIs([UIScreen zj_screenWith] - 24 * [UIScreen zj_screenWScale])
        .bottomSpaceToView(self.underline, 5 * [UIScreen zj_screenHScale]);
    }
    return self;
}



#pragma mark - Setters
- (void)setModel:(ZJStudySpcialModel *)model{
    _model = model;
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", BASEIMAGEURL,model.IMAGEPHOTO_THUMBURL]] placeholderImage:nil];
    self.titleLabel.text = model.CLASS_NAME;
    self.abstract.text = model.CLASS_COMMENT;
    
}


#pragma mark - Getters
- (UIImageView *)imageview{
    if (_imageview == nil){
        _imageview = [UIImageView new];
        _imageview.contentMode = UIViewContentModeScaleToFill;
        _imageview.layer.borderColor = [UIColor zj_colorWithHexString:@"ededed"].CGColor;
        _imageview.layer.borderWidth = 1 * [UIScreen zj_screenWScale];
    }
    return _imageview;
}


- (UILabel *)titleLabel{
    if (_titleLabel == nil){
        _titleLabel = [UILabel new];
        _titleLabel.textColor = [UIColor textBlackColor];
        _titleLabel.font = [UIFont titleTextFont];
        _titleLabel.numberOfLines = 1;
     
    }
    return _titleLabel;
}
- (UILabel *)abstract{
    if (_abstract == nil){
        _abstract = [UILabel new];
        _abstract.textColor = [UIColor textBlackColor];
        _abstract.font = [UIFont titleTextFont];
        _abstract.numberOfLines = 3;
      
    }
    return _abstract;
}



- (UILabel *)underline{
    if (_underline == nil){
        _underline = [UILabel new];
        _underline.backgroundColor = [UIColor viewBGGrayColor];
    }
    return _underline;
}


@end
